/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *  Copyright (C) 2006-2008 XNeur Team
 *
 */

#ifndef _CONFIG_MAIN_H_
#define _CONFIG_MAIN_H_

#define CONFIG_NAME			"xkeylogrc"
#define CONFIG_BCK_NAME			"xkeylogrc~"
#define LOG_NAME			"xkeylog.log"

#define MAX_FLAGS			4
#define MAX_HOTKEYS			11

enum _flag_action
{
	FLAG_LAYOUT_0 = 0,
	FLAG_LAYOUT_1,
	FLAG_LAYOUT_2,
	FLAG_LAYOUT_3,
};

enum _hotkey_action
{
	ACTION_CHANGE_WORD = 0,
	ACTION_CHANGE_STRING,
	ACTION_CHANGE_MODE,
	ACTION_CHANGE_SELECTED,
	ACTION_CHANGECASE_SELECTED,
	ACTION_ENABLE_LAYOUT_0,
	ACTION_ENABLE_LAYOUT_1,
	ACTION_ENABLE_LAYOUT_2,
	ACTION_ENABLE_LAYOUT_3,
	ACTION_REPLACE_ABBREVIATION,
	ACTION_NONE,
};

enum _change_action
{
	CHANGE_INCIDENTAL_CAPS = 0,
	CHANGE_TWO_CAPITAL_LETTER,
	CHANGE_WORD_TO_LAYOUT_0,
	CHANGE_WORD_TO_LAYOUT_1,
	CHANGE_WORD_TO_LAYOUT_2,
	CHANGE_WORD_TO_LAYOUT_3,
	CHANGE_SYLL_TO_LAYOUT_0,
	CHANGE_SYLL_TO_LAYOUT_1,
	CHANGE_SYLL_TO_LAYOUT_2,
	CHANGE_SYLL_TO_LAYOUT_3,
	CHANGE_SELECTION,
	CHANGE_STRING_TO_LAYOUT_0,
	CHANGE_STRING_TO_LAYOUT_1,
	CHANGE_STRING_TO_LAYOUT_2,
	CHANGE_STRING_TO_LAYOUT_3,
	CHANGE_ABBREVIATION,
};

struct _xkeylog_language
{
	char *dir;
	char *name;
	int  group;
	int  fixed;

};

struct _xkeylog_hotkey
{
	int modifiers; // Shift (0x1), Control (0x2), Alt (0x4), Super (0x8)
	char *key;
};

struct _xkeylog_file
{
	char *file;
};

struct _xkeylog_data
{
	int process_id;
};

struct _xkeylog_action
{
	struct _xkeylog_hotkey *action_hotkey;
	struct _list_char *action_command;
};

struct _xkeylog_config
{
	char *version;

	void (*get_library_version) (int *major_version, int *minor_version); // This function MUST be first

	struct _list_char *excluded_apps;
	struct _list_char *auto_apps;
	struct _list_char *manual_apps;
	struct _list_char *layout_remember_apps;
	struct _list_char *window_layouts;

	struct _xkeylog_data *xkeylog_data;
	struct _xkeylog_language *languages;		// Array of languages used in program
	struct _xkeylog_hotkey *hotkeys;			// Array of hotkeys used in program

	int   log_level;				// Maximum level of log messages to print
	int   send_delay;				// Delay before send event (in milliseconds)
	int   total_languages;				// Total languages to work with

	int   grab_mouse;				// Grab mouse or not
	int   save_selection;				// Save selection after convert
	int   save_keyboard_log;			// Save keyboard log
	int   correct_incidental_caps;		// Change iNCIDENTAL CapsLock
	int   correct_two_capital_letter;	// Change two CApital letter
	int   flush_buffer_when_press_enter;  // Flush internal buffer when pressed Enter
	int   dont_process_when_press_enter;   // Don't correct word when pressed Enter

	struct _xkeylog_action *actions;

	const char* (*get_bool_name) (int option);

	int   (*load) (struct _xkeylog_config *p);
	void  (*clear) (struct _xkeylog_config *p);
	int   (*save) (struct _xkeylog_config *p);
	int   (*replace) (struct _xkeylog_config *p);
	void  (*reload) (struct _xkeylog_config *p);
	int   (*kill) (struct _xkeylog_config *p);
	void  (*set_pid) (struct _xkeylog_config *p, int pid);
	int   (*get_pid) (struct _xkeylog_config *p);
	char* (*get_lang_dir) (struct _xkeylog_config *p, int lang);
	char* (*get_lang_name) (struct _xkeylog_config *p, int lang);
	int   (*get_lang_group) (struct _xkeylog_config *p, int lang);
	int   (*find_group_lang) (struct _xkeylog_config *p, int group);
	void  (*add_language) (struct _xkeylog_config *p, const char *name, const char *dir, int group, int fixed);
	const char* (*get_log_level_name) (struct _xkeylog_config *p);
	void  (*uninit) (struct _xkeylog_config *p);
};

struct _xkeylog_config* xkeylog_config_init(void);

#endif /* _CONFIG_MAIN_H_ */
